-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support to multiple property pairs in sprint #39381
Conversation
Bump! |
I think this should have a compat note in the docstring, but otherwise looks good to me. |
@simeonschaub Done! I think I just need to add the information to NEWS.md, but I will wait for approval to avoid multiple rebases. |
Bump! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Sometimes it is required to pass multiple properties to `IOContext` in `sprint`. For example, if we want to print with `:compact` and `:limit` set to true. Currently, the only possible way to do this is creating an `IOContext` using a dummy `IOBuffer` with those parameters. Hence, this commit allows to pass a vector of pairs `:key=>value` to `context` keyword of `sprint` so that we can easily set multiple properties. This is not a breaking change, and no performance regression was identified when using the previous function signatures.
Co-authored-by: Rafael Fourquet <[email protected]>
Done @rfourquet ! Thanks for the review. |
* Add support to multiple property pairs in sprint Sometimes it is required to pass multiple properties to `IOContext` in `sprint`. For example, if we want to print with `:compact` and `:limit` set to true. Currently, the only possible way to do this is creating an `IOContext` using a dummy `IOBuffer` with those parameters. Hence, this commit allows to pass a vector of pairs `:key=>value` to `context` keyword of `sprint` so that we can easily set multiple properties. This is not a breaking change, and no performance regression was identified when using the previous function signatures. * Add compat annotation to sprint * Update base/strings/io.jl Co-authored-by: Rafael Fourquet <[email protected]> * Update sprint docstring * Update NEWS.md * Move NEWS.md entry to the correct place Co-authored-by: Rafael Fourquet <[email protected]>
* Add support to multiple property pairs in sprint Sometimes it is required to pass multiple properties to `IOContext` in `sprint`. For example, if we want to print with `:compact` and `:limit` set to true. Currently, the only possible way to do this is creating an `IOContext` using a dummy `IOBuffer` with those parameters. Hence, this commit allows to pass a vector of pairs `:key=>value` to `context` keyword of `sprint` so that we can easily set multiple properties. This is not a breaking change, and no performance regression was identified when using the previous function signatures. * Add compat annotation to sprint * Update base/strings/io.jl Co-authored-by: Rafael Fourquet <[email protected]> * Update sprint docstring * Update NEWS.md * Move NEWS.md entry to the correct place Co-authored-by: Rafael Fourquet <[email protected]>
Hi there. A pity that namedtuple support has not been implemented in addition. # done
sprint(show, v; context=(:compact=>true, :limit=>true))
# still todo
sprint(show, v; context=(; compact=true, limit=true)) # more julian IMHO I'am a bit short on time those days to pr it EDITED if context isa NamedTuple
f(IOContext(s, pairs(context)...), args...) should be enough |
Sometimes it is required to pass multiple properties to
IOContext
insprint
. For example, if we want to print with:compact
and:limit
set to true. Currently, the only possible way to do this is creating an
IOContext
using a dummyIOBuffer
with those parameters. Hence, thiscommit allows to pass a vector of pairs
:key=>value
tocontext
keyword of
sprint
so that we can easily set multiple properties.This is not a breaking change, and no performance regression was
identified when using the previous function signatures.